/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package gsb.test;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import java.util.List;
import modele.DAO;
import modele.Medecin;

/**
 *
 * @author fseigneur
 */
public class MedsActivity extends ListActivity {
    private List<Medecin> lesMeds;
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        //on va chercher la vue 
        setContentView(R.layout.medliste);
        TextView label = (TextView) findViewById(R.id.label);
        Intent inter = getIntent();
        String leDep = inter.getStringExtra("leDep");
        DAO.getLesMeds(leDep);
        lesMeds = DAO.getLesMeds(leDep);
        
        label.setText("Liste des medecins du : "+leDep);
        
        MedAdapter adapter = new MedAdapter(lesMeds, this);
        setListAdapter(adapter);
        

        @Override
    protected void onListItemClick(ListView l, View v, int position, long id) { //Clique sur la ligne
        Intent callIntent = new Intent(Intent.ACTION_CALL); 
        callIntent.setData(Uri.parse("tel:"+ ((Medecin)l.getItemAtPosition(position)).getTel())); //Préparation de l'appel
        startActivity(callIntent); 
    }


    }


}

